-
Notifications
You must be signed in to change notification settings - Fork 11
Fixes NPE when spam clicking right click with a chisel #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
WalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
SmithingPlus/BitsRecovery/CollectibleBehaviorScrapeCrucible.cs (2)
30-37: Consider makingblockSelnullable for consistency.
OnHeldInteractStepuses a non-nullableBlockSelectionparameter whileOnHeldInteractStart(line 13) andOnHeldInteractStop(line 42) both accept nullableBlockSelection?. For consistency and defensive coding, consider updating this signature to match the pattern:public override bool OnHeldInteractStep(float secondsUsed, ItemSlot slot, EntityAgent byEntity, - BlockSelection blockSel, + BlockSelection? blockSel, EntitySelection entitySel, ref EnumHandling handling) { + if (blockSel is null) return false; byEntity.StartAnimation("knifecut"); handling = EnumHandling.PreventDefault; return secondsUsed < 1.5; }
130-135: Update method signature to accept nullableBlockSelection?.After the fix,
TryGetSelectedGroundStorageis called at line 52 with aBlockSelection?argument. To avoid potential compiler warnings and maintain consistency, update the method signature:private static BlockEntityGroundStorage? TryGetSelectedGroundStorage(EntityPlayer entityPlayer, - BlockSelection blockSel) + BlockSelection? blockSel) { + if (blockSel?.Position is null) return null; var blockEntity = entityPlayer.World.BlockAccessor.GetBlockEntity(blockSel.Position); return blockEntity as BlockEntityGroundStorage; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
SmithingPlus/BitsRecovery/CollectibleBehaviorScrapeCrucible.cs(2 hunks)
🔇 Additional comments (2)
SmithingPlus/BitsRecovery/CollectibleBehaviorScrapeCrucible.cs (2)
39-44: Good fix for the NPE issue.Making
blockSelnullable correctly aligns with the base class contract and matches the pattern already used inOnHeldInteractStart(line 13).
51-51: Null check correctly prevents the NPE.The guard clause effectively addresses the server-side crash reported in issue #106 by ensuring both
blockSeland itsPositionproperty are non-null before proceeding.
This should be marked as nullable :(
May resolve #106
Summary by CodeRabbit